<template>
  <div class="FormCclass">
    <el-form :model="student" ref="student" label-width="100px" class="demo-ruleForm">
        <el-form-item label="姓名" prop="name" style="width:300px">
            <el-input v-model="student.name"></el-input>
        </el-form-item>
        <el-form-item label="年龄" prop="age" type="numeber" style="width:300px">
            <el-input v-model="student.age"></el-input>
        </el-form-item>
        <el-form-item label="学号" prop="学号" style="width:300px">
            <el-input v-model="student.xuehao"></el-input>
        </el-form-item>
        <el-form-item label="性别" prop="xingbie">
            <el-radio-group v-model="student.xingbie">
            <el-radio label="男"></el-radio>
            <el-radio label="女"></el-radio>
            </el-radio-group>
        </el-form-item>
        <!-- 列表带参数携带过来的 -->
        <el-form-item label="班级" prop="banji">
            <el-select v-model="student.banji" placeholder="请选择班级！">
            <el-option :label="stu.name" :value="stu.id" v-for="(stu,index) in banjiData" :key='index'></el-option>
            <!-- <el-option  value="1706"></el-option>
            <el-option  value="1706"></el-option> -->
            </el-select>
        </el-form-item>

        <!--这是写死的值 -->
        <!-- <el-form-item label="班级" prop="banji">
            <el-select v-model="student.banji" placeholder="请选择班级！">
            <el-option value="1706"></el-option>
            <el-option value="1706"></el-option>
            <el-option value="1706"></el-option>
            </el-select>
        </el-form-item> -->

        <el-form-item label="爱好" prop="aihao">
            <el-checkbox-group v-model="student.aihao">
                <el-checkbox label="唱歌" name="type"></el-checkbox>
                <el-checkbox label="睡觉" name="type"></el-checkbox>
                <el-checkbox label="阅读" name="type"></el-checkbox>
                <el-checkbox label="爬山" name="type"></el-checkbox>
            </el-checkbox-group>
        </el-form-item>
        <el-form-item label="照片" prop="zhaopian" style="width:300px">
            <el-input v-model="student.zhaopian"></el-input>
        </el-form-item>
        <el-form-item label="简介" prop="jianjie" style="width:300px">
            <el-input v-model="student.jianjie"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="saveData({student:student,router:$router})">保存</el-button>
            <el-button @click="goBack()" >返回</el-button>
        </el-form-item>
    </el-form>
  </div>
</template>

<script>

import { mapState ,mapActions } from 'vuex'

export default {
    mounted(){
        this.className = this.banjiData
        // console.log(this.className)
        // this.$route.params.id && (this.student = this.$route.params)
        if(this.$route.params.id) {
            this.student = this.$route.params
        }
    },
    data() {
      return {
        student: {
            aihao:[]
        },
        className:[] 
      }
    },
    methods: {
      ...mapActions(['saveData'])
    },
    computed:{
        ...mapState(['banjiData'])
    }
  }
</script>

<style>
.FormCclass{
    margin-top: 20px;
    margin-left: 25%;
}

</style>
